package xyz.zhno.project.commons.core.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常父类
 * @author zh_o
 * @date 2020-10-31
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ProjectException extends RuntimeException {

    private static final long serialVersionUID = 7014681865348984139L;

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误描述信息
     */
    private String message;

    /**
     * 通过枚举抛出异常
     * @param codeEnum 异常枚举
     */
    public ProjectException(ProjectExceptionCodeEnum codeEnum) {
        this.code = codeEnum.getCode();
        this.message = codeEnum.getMessage();
    }

    /**
     * 自定义异常秒速、错误码
     * @param code 错误码
     * @param message 异常描述信息
     */
    public ProjectException(String code, String message) {
        this.code = code;
        this.message = message;
    }
}
